package com.ellricky.baselib.adapter.student;

import android.app.Activity;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.andr.common.ui.adapter.BaseRecyclerAdapter;
import com.andr.common.ui.adapter.SmartViewHolder;
import com.andr.common.util.EmptyUtil;
import com.andr.common.util.StrUtil;
import com.ellricky.baselib.R;
import com.ellricky.baselib.entity.student.StudentList;
import com.ellricky.baselib.util.GlideUtil;

import de.hdodenhof.circleimageview.CircleImageView;

public class StuManageAdapter extends BaseRecyclerAdapter<StudentList> {

    private Activity activity;

    public StuManageAdapter(Activity activity) {
        super(R.layout.base_adapter_stu_manage);
        if (activity != null) {
            this.activity = activity;
        }
    }


    @Override
    public void onBindViewHolder(SmartViewHolder holder, StudentList model, final int position) {
        View itemView = holder.itemView;

        // 头像
        CircleImageView iv = itemView.findViewById(R.id.ivPic);

        TextView tvName = itemView.findViewById(R.id.tvName);
        // 姓名+性别
        String name = StrUtil.filterEmpty(model.getMemberName());
        String sexName = StrUtil.filterEmpty(model.getMemberSex());
        if (!EmptyUtil.isEmpty(sexName)) {
            name += "(" + sexName + ")";
        }
        tvName.setText(name);

        // 请假状态图标
        ImageView ivState = itemView.findViewById(R.id.ivStateLabel);
        ivState.setVisibility(View.GONE);

        String baseHour = StrUtil.filterEmpty(model.getBasicNum());
        holder.text(R.id.tvBaseHour, EmptyUtil.isEmpty(baseHour) ? "" : baseHour + "课时");

        String specialHour = StrUtil.filterEmpty(model.getSpecialNum());
        holder.text(R.id.tvSpecialHour, EmptyUtil.isEmpty(specialHour) ? "" : specialHour + "课时");

        holder.text(R.id.tvBirth, model.getBirthday()+"");
        holder.text(R.id.tvAge, model.getMemberAge());

    }
}
